<template>
	<view style="background-color: #fff;">
		<view style="display: flex;justify-content: space-around;height: 230upx;">
			<view style="margin-top: 30upx;">
				<image style="width: 170upx;height: 150upx;" src="../../../static/tzzlogo.png" mode=""></image>
			</view>
			<!-- <view style="height: 200upx;">
				<view style="margin-top: 55upx;">
					当时算力 <text style="color: #D5832D;margin-left: 15upx;"> {{wheel}}轮</text>
				</view>
				<view style="font-size: 32upx;color: #D5832D;font-weight: 600;text-align: center;">
					{{zichan_power}}
				</view>
			</view> -->
			<view style="height: 200upx;">
				<view style="margin-top: 10upx;" @click="obtain">
					<text>待释放易通值</text><text style="margin-left: 20upx;"> > </text>
					<view>{{tzz}}</view>
				</view>
				<view @click="totzzdh">
					<text>已释放易通值</text><text style="margin-left: 20upx;"> > </text>
					<view>{{tzz_release}}</view>
				</view>
			</view>
		</view>
		<view style="border-top: 1upx solid #ccc;border-bottom: 1upx solid #ccc;">
			<view class="uni-swiper-msg" style="padding: 12upx;width: 726upx;">
				<view class="uni-swiper-msg-icon" style="width: 180upx;">
					<view style="color: #b25415;padding-left: 10upx;">易通值</view>
				</view>
				<swiper vertical="true" autoplay="true" circular="true" interval="3000" class="flex">
					<swiper-item v-for="(item, index) in project" :key="index">
						<view style="font-size: 28upx;" class="ellipsis-1">
						<text @click="toarticlexq(item.id)">{{item.title}}</text>
						</view>
					</swiper-item>
				</swiper>
				<view class="uni-swiper-msg-icon" style="width: 220upx;">
					<view @click="toarticle" style="color: #b25415;padding-left: 10upx;">更多全球好项目</view>
				</view>
			</view>
		</view>
		<view style="height: 100upx;color: #B81738;padding: 30upx;">
			<view>
				<view style="font-size: 32upx;font-weight: 550;">
					{{qy_info}}
				</view>
				<!-- <view style="margin-left: 30upx;">
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
				</view> -->
			</view>
			<!-- <view>
				<view style="font-size: 32upx;font-weight: 550;">
					GA价值
				</view>
				<view style="margin-left: 30upx;">
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
					<view style="font-size: 24upx;">
						GA来源 亿万红包~GA等你抢
					</view>
				</view>
			</view> -->
		</view>
		<view class="container">
			<!-- 带上拉加载的数据列表 -->
			<view class="big-loading-text loading-text" style="height: 80upx;line-height: 80upx;">
				<text>时间</text>
				<text>数量</text>
				<text>状态</text>
			</view>
			<!-- 数据列表 -->
			<scroll-view scroll-y="true" style="height: 560upx;">
				<view class="loading-text" @click="toarticlexq(value.projectid)" v-for="(value,key) in list" :key="key" style="height: 50upx;line-height: 50upx;">
					<text style="display: block;width: 300upx;">{{value.time}}</text>
					<text>{{value.tzz}}</text>
					<text v-if="value.status==0">待签约</text>
					<text v-if="value.status==5">已签约</text>
				</view>
			</scroll-view>
		</view>
		<view style="display: flex;background-color: #fff;width: 100%;padding-top: 5px;position: fixed;bottom: 5upx;height: 100upx;background-color: #05052B;color: #fff;justify-content: space-around;">
			<view style="display: flex;flex-direction: column;" @click="getbuy">
				<image style="width: 50upx;height: 50upx;" src="../../../static/goumai.png" mode=""></image>
				<view>
					购买
				</view>
			</view>
			<!-- <view style="display: flex;flex-direction: column;" @click="togetbuy">
				<image style="width: 50upx;height: 50upx;margin-left: 30upx;" src="../../../static/duihuan.png" mode=""></image>
				<view>
					兑换资产
				</view>
			</view> -->
			<view style="display: flex;flex-direction: column;" @click="getsale">
				<image style="width: 50upx;height: 50upx;" src="../../../static/guamai.png" mode=""></image>
				<view>
					挂卖
				</view>
			</view>
		</view>
	</view>
</template>

<script> 
import uniLoadMore from '../../../components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				qy_info:'',
				tzz_release:'',
				tzz:'',
				project:'',
				s_exchange:'',
				list:[],
				wheel:'',
				zichan_power:'',
				nzichan_power:'',
				bz:'',
				bz_release:'',
				res:[],
				openid:'',
				systemInfo:[],
				active:"active",
				index:1,
				topres:1,
				newsList:[],
				loadingText: '加载中...',
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				load: 0,
				page: 1,
				timer:{},
			}
		},
		onLoad: function(e) {
			// uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.getarticle()
					this.getassets()
					this.getassets1()
					this.getnewsList()
					//页面一加载时请求一次数据`
					// uni.hideLoading()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.getnewsList()
		},
		// 上拉加载
		onReachBottom(){
			if (this.timer != null) {
				clearTimeout(this.timer)
			}
			this.timer = setTimeout(()=> {
				this.getmorenews()
			}, 1000);
		},
		methods: {
			//获取项目列表
			getarticle() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
						this.project = res.data.project
					},
					fail: () => {},
					complete: () => {}
				});
			},
			toarticlexq(id){
				// console.log(id)
				uni.navigateTo({
					url:'articlexq?id=' + id
				})
			},
			totzzdh() {
				uni.navigateTo({
					url:'tzzdh'
				})
			},
			obtain() {
				uni.navigateTo({
					url:'obtain/obtain?type='+ 3
				})
			},
			//获取资产值信息
			getassets() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.tzz_index&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
						this.tzz_release = res.data.tzz_release
						this.tzz = res.data.tzz
						this.qy_info = res.data.qy_info
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getassets1() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=tzz.exchange_list&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
						this.list = res.data.exchangelog
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getbuy() {
				uni.navigateTo({
					url:'buy1'
				})
			},
			getsale() {
				uni.navigateTo({
					url:'sale1'
				})
			},
			toarticle() {
				uni.navigateTo({
					url:'article'
				})
			},
			getmorenews() {
				this.page++;//每触底一次 page +1
				if (this.loadingType !== 0) {//loadingType!=0;直接返回
					return false;
				}
				this.loadingType = 1;
				uni.showNavigationBarLoading();//显示加载动画
				uni.request({
					url:this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.tzz&app=' + this.page,
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: function(res) {
						if (res.data.tzz == '') {//没有数据
							this.loadingType = 2;
							uni.hideNavigationBarLoading();//关闭加载动画
							return;
						}
						// this.newsList = this.newsList.concat(res.data.tzz);//将数据拼接在一起
						this.loadingType = 0;//将loadingType归0重置
						uni.hideNavigationBarLoading();//关闭加载动画
					}
				});
			},
			// 第一次请求数据，刷新
			
			getnewsList() {
				// this.setTopAjax()
				this.loadingType = 0;
				uni.showNavigationBarLoading();
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.tzz&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => { 
						// console.log(res)
						this.page++;//得到数据之后page+1
						this.topres = res.data.leiji_tzz;
						this.newsList = res.data.tzz;
						uni.hideNavigationBarLoading();
						uni.stopPullDownRefresh();//得到数据后停止下拉刷新
						// console.log(this.newsList)
					}
				});
			},
		},
	}
</script>
<style>
.container {
	background-color: #fff;
}
.loading-text {
	margin: ;
	background-color: fff;
	display: flex;
}

.loading-text text:nth-child(1) {
	padding-left: 15upx;
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 2;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(2) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 1;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(3) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 1;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(4) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 5;
	text-align: center;
	font-size: 26upx;
}
.all_add {
	height: 80upx;
	text-align: center;
	line-height: 80upx;
	background-color: rgb(254,162,61);
	color: #fff;
}
.big-loading-text {
	font-weight: 550;
	border-bottom: 2upx solid rgb(243,243,243);
}
uni-page-body{height:100%;}
</style>

